package com.atguigu.gulimall.product.sync;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

class Thread1 implements Runnable {

    @Override
    public void run() {

    }
}

class Thread2 implements Callable {


    @Override
    public Integer call() throws Exception {
        return 200;
    }
}

public class CallableTask {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
//        new Thread(new Thread1(),"1").start();
        FutureTask futureTask = new FutureTask(new Thread2());

        FutureTask<Integer> futureTask1 = new FutureTask(() -> {
            System.out.println(Thread.currentThread().getName() + "进入callable");
            return 1024;
        });
        new Thread(futureTask, "A").start();
        new Thread(futureTask1, "B").start();
        System.out.println(futureTask.get());

        System.out.println(futureTask1.get());

    }
}
